#pragma once

#include <iostream>
#include <cstdio>
#include <ctime>

//定义等级
#define LDEBUG 0
#define LINFO 1
#define LERR  2

//可以打印的日志等级最低限制
#define LDEFAULT LDEBUG

//日志宏函数
#define LOG(level, format, ...) { \
    if(level >= LDEFAULT) { \
        time_t t = time(nullptr); \
        struct tm *lt = localtime(&t); \
        char time_tmp[32] = {0}; \
        strftime(time_tmp, 31, "%m-%d %T", lt); \
        printf("[%s][%s:%d]" format "\n", time_tmp, __FILE__, __LINE__, ##__VA_ARGS__); \
    } \
}

#define DEBUG(format, ...) LOG(LDEBUG, format, ##__VA_ARGS__);
#define INFO(format, ...) LOG(LINFO, format, ##__VA_ARGS__);
#define ERR(format, ...) LOG(LERR, format, ##__VA_ARGS__);